<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@page import="com.ownershipstatistic.OwnershipStatisticVO"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List list = (List)request.getAttribute("list");
%>
<html> 
	<head> 
	<title>机动车保有量统计表打印页</title> 
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
	<!--media=print 这个属性可以在打印时有效--> 
	<style media=print> 
		.Noprint{display:none;}<!--用本样式在打印时隐藏非打印项目--> 
		.PageNext{page-break-after: always;}<!--控制分页-->
	</style>

	<style>
		.style_tab_head 
		{ 
		font-family: "仿宋_GB2312"; 
		font-size: 22pt; 
		}
		.forcePage
		{
		page-break-after : always;
		}
		.style_td 
		{ 
		border-bottom: 1 solid #000000; 
		border-left: 1 solid #000000; 
		border-right: 0 solid #ffffff; 
		border-top: 0 solid #ffffff;
		text-align: center;
		height : 33px;
		}
		.style_tab 
		{ 
		border-color: #000000 #000000 #000000 #000000; 
		border-style: solid; 
		border-top-width: 2px; 
		border-right-width: 2px; 
		border-bottom-width: 1px; 
		border-left-width: 1px; 
		}
		.NOPRINT { 
		font-family: "宋体"; 
		font-size: 9pt; 
		}
	</style>
	</head>
	
	<body>
		<center class="Noprint"> 
			<p> 
				<input type=button value=返回 onclick="window.history.back()"> 
			</p> 
		</center>
		<%
		int sum = 0;
		int pageCount = 0;
		if (null != list) {
			sum = list.size();
			if (sum % 15 == 0) {
				pageCount = sum % 16;
			} else {
				pageCount = sum / 16 + 1;
			}
		}
		for (int i=0; null!=list && i<pageCount; i++) {
			if (i!=0) {
		%>
		<div class="forcePage">&nbsp;</div>
		<%
			}
		%>
		<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0">
			<tr>
				<td width="35%">&nbsp;</td> 
				<td width="35%">&nbsp;</td> 
				<td width="30%">&nbsp;</td>
			</tr>
			<tr>
				<td width="35%">&nbsp;</td> 
				<td width="35%">&nbsp;</td> 
				<td width="30%">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="3" align="center" class="style_tab_head">机动车保有量统计表                （ 村 级 ）</td> 
			</tr> 
			<tr>
				<%
					//默认第一个的中队名称
					OwnershipStatisticVO vo0 = (OwnershipStatisticVO) list.get(0);
					String squadron = "&nbsp;";
					if (vo0.getSquadron() != null && !"".equals(vo0.getSquadron())) {
						squadron = vo0.getSquadron();
					}
				%>
				<td width="35%">&nbsp;</td> 
				<td width="35%">&nbsp;</td> 
				<td width="30%"><%=squadron %></td>
			</tr>
			<tr>
				<td colspan="3">
					<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="style_tab"> 
						<tr> 
							<td width="10%" class="style_td">屯</td>
							<td width="10%" class="style_td">屯长</td>
							<td width="15%" class="style_td">联系电话</td>
							<td width="10%" class="style_td">摩托车</td>
							<td width="10%" class="style_td">三轮车</td>
							<td width="15%" class="style_td">农用四轮车</td>
							<td width="10%" class="style_td">小型车</td>
							<td width="10%" class="style_td">大型车</td>
							<td width="10%" class="style_td">合计</td>
						</tr>
						<%
							for (int j=i*16; j<(i+1)*16 && j<list.size(); j++) {
								OwnershipStatisticVO vo = (OwnershipStatisticVO)list.get(i);
								String village = "&nbsp;";
								if ( vo.getVillage()!=null && !"".equals(vo.getVillage())) {
									village = vo.getVillage();
								}
								String villageHead = "&nbsp;";
								if ( vo.getVillagehead()!=null && !"".equals(vo.getVillagehead())) {
									villageHead = vo.getVillagehead();
								}
								String phonenumber = "&nbsp;";
								if ( vo.getPhonenumber()!=null && !"".equals(vo.getPhonenumber())) {
									phonenumber = vo.getPhonenumber();
								}
								String motorcycle = "&nbsp;";
								if ( (Integer)vo.getMotorcycle() != null ) {
									motorcycle = String.valueOf(vo.getMotorcycle());
								}
								String tricycle = "&nbsp;";
								if ( (Integer)vo.getTricycle() != null ) {
									tricycle = String.valueOf(vo.getTricycle());
								}
								String farmtransporter = "&nbsp;";
								if ( (Integer)vo.getFarmtransporter() != null ) {
									farmtransporter = String.valueOf(vo.getFarmtransporter());
								}
								String car = "&nbsp;";
								if ( (Integer)vo.getCar() != null ) {
									car = String.valueOf(vo.getCar());
								}
								String bus = "&nbsp;";
								if ( (Integer)vo.getBus() != null ) {
									bus = String.valueOf(vo.getBus());
								}
								String count = "&nbsp;";
								if ( (Integer)vo.getSum() != null ) {
									count = String.valueOf(vo.getSum());
								}
						%>
						<tr> 
							<td width="10%" class="style_td"><%=village%></td>
							<td width="10%" class="style_td"><%=villageHead%></td>
							<td width="15%" class="style_td"><%=phonenumber%></td>
							<td width="10%" class="style_td"><%=motorcycle%></td>
							<td width="10%" class="style_td"><%=tricycle%></td>
							<td width="15%" class="style_td"><%=farmtransporter%></td>
							<td width="10%" class="style_td"><%=car%></td>
							<td width="10%" class="style_td"><%=bus%></td>
							<td width="10%" class="style_td"><%=count%><td>
						</tr>
						<%
							}
						%>
					</table>
				</td> 
			</tr>
		</table>
		<%
		}
		%>
	</body> 
</html>
<script language="javascript">
	var hkey_root="HKEY_CURRENT_USER" ; 
	var hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; 
	var hkey_key;
	function doPrint() {    
		//直接调用WebBrowser的打印，要打印预览的话是ExecWB(7,1) 直接打印ExecWB(6,6)
     	document.all.WebBrowser.ExecWB(6,6); 
	} 
	//设置纸张方向 
	function setupLandscape() { 
		try{ 
			var wsShell= new ActiveXObject("WScript.Shell"); 
			//打印页面的Menubar必须可见，此操作类似按键盘上的Alt+F+U也就是 调出页面设置对话框 
			wsShell.sendKeys('%fu'); 
			//此操作类似按键盘上的Alt+A也就是 设置横向打印 
			wsShell.sendKeys('%a');
			//此操作类似按键盘上的Alt+O也就是 设置竖向打印 
			//wsShell.sendKeys('%o'); 
			//此操作类似按键盘上的回车 页面设置对话框的默认焦点在 确定上 所以直接确定 
			wsShell.sendKeys('{ENTER}'); 
		} 
		catch(e){} 
	} 
	//设置默认的页眉页脚 
	function setupPage() { 
		try{ 
		var RegWsh = new ActiveXObject("WScript.Shell"); 
			hkey_key="header" 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") 
			hkey_key="footer" 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&b") //去掉了&u 因为我不想显示当前打印页的网址 
			hkey_key="margin_bottom"; 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.39"); //0.39相当于把页面设置里面的边距设置为10 
			hkey_key="margin_left"; 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.39"); 
			hkey_key="margin_right"; 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.39"); 
			hkey_key="margin_top"; 
			RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"0.39"); 
		} 
		catch(e){} 
	} 
	setTimeout("setupLandscape()",1000); 
	setTimeout("setupPage()",2000); 
	setTimeout("doPrint()",3000); 
</script>